<?
/*
 * Copyright 2004-2005 Sigve Indregard.
 *
 * This file is part of Laivsys.
 *
 * Laivsys is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Laivsys is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Laivsys; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/*
 * $Id: rollerteksteksport.php 6 2005-07-11 23:14:47Z say $
 */
 
include("../db.php");
include("auth.php");
include("rollerinclude.php");

header("Content-type: text/plain");
header("Content-disposition: attachment; filename=roller.txt");
$delim="\r\n";


echo "ROLLEOVERSIKT:$delim";
echo "**************$delim";

$sql = "SELECT rollekode, CONCAT_WS(' ',rollenavn, familienavn), tentativcasting FROM r_Rolle WHERE LaivID=$laivid ORDER BY rollekode";

$roller = mysql_query($sql);

while ($rolle = mysql_fetch_row($roller)) {
	foreach ($rolle as $value)
		echo str_pad(substr($value, 0, 22), 24, " ");
	echo $delim;
}

echo "$delim{$delim}ROLLER$delim";
echo "******$delim";

$sql = "SELECT rollekode, rollenavn, familienavn, tentativcasting, alder, kjonn, beskrivelse FROM r_Rolle WHERE LaivID=$laivid ORDER BY rollekode";
$roller=mysql_query($sql);


while ($rolle = mysql_fetch_assoc($roller)) {
	echo $rolle['rollekode'].$delim;
	echo $rolle['rollenavn']." ".$rolle['familienavn'];
	echo " (".$rolle['kjonn'].", ".$rolle['alder']." �r)$delim";
	echo "Tentativ casting: {$rolle['tentativcasting']}$delim";
	echo "{$delim}Rollebeskrivelse:$delim";
	echo wordwrap($rolle['beskrivelse'], 72, $delim);
	echo "$delim$delim--$delim";
}
?>
